@{   
    
    Layout = "~/Views/Shared/_LayoutJtable.cshtml";       
}
@{ViewBag.Title = "Gestione Datos";}
@section CssImport{<link href="@Url.Content("~/Scripts/validationEngine/validationEngine.jquery.css")" rel="stylesheet" type="text/css" />}
@section JavascriptImport{
<script type="text/javascript" src="@Url.Content("~/Scripts/validationEngine/jquery.validationEngine.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/validationEngine/jquery.validationEngine-en.js")"></script>}
<div class="filtering"><form>
<label>Indroduzca texto para filtrar: <input type="text" name="filter" id="filter" /></label>
<button type="submit" id="LoadRecordsButton" class="button medium green">Filtrar Datos</button>
</form></div>
<div id="MyTableContainer"></div>
<script type="text/javascript">
     $(document).ready(function () {
     $('#MyTableContainer').jtable({
         title: 'DUA_Direccion',
         paging: true,
         pageSize: 20,
         sorting: true,
         defaultSorting: 'Id ASC',
         actions: {
             listAction: '@Url.Action("JSONPagedListByFilter")',
             deleteAction: '@Url.Action("JSONDelete")',
             updateAction: '@Url.Action("JSONUpdate")',
             createAction: '@Url.Action("JSONCreate")'
         },
         fields:
         {
          Id: {
                 key: true,
                 create: false,
                 edit: false,
                 list: false
             }
             ,
             Descripcion: {
                 title:'Descripcion',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             NombreAvenida: {
                 title:'NombreAvenida',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             CodigoPostal: {
                 title:'CodigoPostal',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             Acera: {
                 title:'Acera',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             Longitud: {
                 title:'Longitud',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             Latitud: {
                 title:'Latitud',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             GUID: {
                 type: 'hidden'
             }
             ,
             Numero: {
                 title:'Numero',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             EsPrincipal: {
                 title:'EsPrincipal',
                 create: true,
                 edit: true,
                 list: true,
                 type: 'checkbox',
                 values:{'false':'Desactivado','true':'Activado'},
                 sorting: false
             }
             ,
             PersonaId_FK:{
                 title : 'DUA_Persona',
                 create : true,
                 edit : true,
                 list : true,
                 options : '@Url.Action("../Persona/JSONGetElementsForDropDownList")'
             }
             ,
             TipoDireccionId_FK:{
                 title : 'DUA_TipoDireccion',
                 create : true,
                 edit : true,
                 list : true,
                 options : '@Url.Action("../TipoDireccion/JSONGetElementsForDropDownList")'
             }
},
formCreated: function (event, data) {data.form.validationEngine();},
formSubmitting: function (event, data) {return data.form.validationEngine('validate');},
formClosed: function (event, data) { data.form.validationEngine('hide'); data.form.validationEngine('detach'); }
});
$('#LoadRecordsButton').click(function (e) {e.preventDefault();$('#MyTableContainer').jtable('load', {filter: $('#filter').val()});});
$('#LoadRecordsButton').click();
});
</script>

